var t = require("../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        info: {
            rewards_each: "---",
            team_nums: "---",
            is_settle: "---",
            no_settle: "---"
        },
        activeName: 0,
        dataList: [],
        titleArr: [],
        isLoadMore: !0
    },
    onLoad: function(t) {
        this.data.activeName = 0, this.data.titleArr = [ "全部", "未结算", "已结算", "已失效" ], this.setData({
            titleArr: this.data.titleArr
        }), this.setNewArr();
    },
    setNewArr: function() {
        var t = this;
        this.data.dataList = [], this.data.titleArr.forEach(function(a, e) {
            t.data.dataList.push({
                isLoadMore: !0,
                page: 1,
                total_page: 0,
                list: []
            });
        }), console.log("dataList:::", this.data.dataList), this.handleClick();
    },
    handleClick: function(e) {
        e && (this.data.activeName = e.detail.name);
        var i = this;
        if (this.data.dataList[i.data.activeName].list.length > 0) this.setData({
            isLoadMore: this.data.dataList[i.data.activeName].isLoadMore
        }); else {
            var s = this.data.activeName, o = a.getNetAddresss("plugin.order-quantity-bonus.frontend.controllers.center.index");
            a._postNetWork({
                url: o,
                data: {
                    record_type: [ "", "no_settle", "is_settle", "invalid" ][s]
                },
                success: function(a) {
                    wx.hideLoading();
                    var e, o = a.data;
                    1 == o.result ? (wx.setNavigationBarTitle({
                        title: o.data.info.name
                    }), i.setData((e = {
                        info: o.data.info
                    }, t(e, "dataList[" + s + "].isLoadMore", !0), t(e, "dataList[" + s + "].total_page", o.data.list.last_page), 
                    t(e, "dataList[" + s + "].list", o.data.list.data), e))) : wx.showToast({
                        title: o.msg,
                        duration: 1e3,
                        icon: "none"
                    });
                },
                fail: function(t) {
                    wx.hideLoading(), console.log(t.msg);
                }
            });
        }
    },
    _getMoreData: function() {
        var e = this, i = this.data.activeName;
        if (this.setData(t({}, "dataList[" + i + "].isLoadMore", !1)), !(this.data.dataList[i].page >= this.data.dataList[i].total_page)) {
            this.data.dataList[i].page = this.data.dataList[i].page + 1;
            var s = a.getNetAddresss("plugin.order-quantity-bonus.frontend.controllers.center.index");
            s += "&page=" + this.data.dataList[i].page, a._getNetWork({
                url: s,
                data: {
                    record_type: [ "", "no_settle", "is_settle", "invalid" ][i]
                },
                success: function(a) {
                    var s = a.data;
                    if (1 == s.result) {
                        var o, d = s.data;
                        e.setData((t(o = {}, "dataList[" + i + "].isLoadMore", !0), t(o, "dataList[" + i + "].list", e.data.dataList[i].list.concat(d.data)), 
                        o));
                    } else {
                        var n;
                        e.setData((t(n = {}, "dataList[" + i + "].isLoadMore", !1), t(n, "dataList[" + i + "].page", e.data.dataList[i].page - 1), 
                        n));
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});